<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="navbar.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'new_document.jsp' starting page</title>
	<link rel="stylesheet" type="text/css" href="styles/css/bootstrap.min.css" />
  </head>
  
  <body class="body">
    <div class="container" style="margin-top:60px;width:960px;margin-left:auto;margin-right:auto;">
	  <div class="row">
	 
	 
	  <!-- 导入左侧部分 -->
		<jsp:include page="side.jsp">
			<jsp:param value="document" name="tag"/>
		</jsp:include>
	
	
	<div class="span9">
	 <form action="document.jspx?m=update" method="post" id="myform">
        <fieldset>
          <legend>编辑资料</legend>
          <div class="control-group">

            <label class="control-label" for="input01">标题</label>
            <div class="controls">
              <input style="height:28px;" type="text" class="span9" id="documentName" x-webkit-speech="undefined" name="documentName" value="${requestScope.document.documentName }"><br />
			  <span id="span1" style="color:red;"></span>
            </div>
          </div>
		
             <div class="control-group">
            <label class="control-label" for="input01">内容</label>
            <div class="controls">

              <textarea  id="desc" name="desc"  class="span9" rows="15" >${requestScope.document.desc }</textarea><br />
			  <span id="span2" style="color:red;"></span>
            </div>
          </div>
           
			
			 
         

          <div class="form-actions">
            <button type="submit" class="btn btn-primary" id="btnSubmit">保存</button>
            <a href="document.jspx" class="btn">返回</a>
          </div>
		  <input type="hidden" name="documentId" value="${requestScope.document.documentId }" />
        </fieldset>
     </form>          
        
		</div>
		<div class="span3">
			
		</div>
	  </div>
	</div>
	
	
	
	<script type="text/javascript" src="styles/jquery/jquery.js"></script>

	<script type="text/javascript">
	    var editor = new baidu.editor.ui.Editor();
	    editor.render("myEditor");
	
		$(document).ready(function(){
			$("#btnSubmit").click(function(){
				var documentName = $("#documentName").val();
				if(documentName.trim().length == 0){
					$("#span1").html("资料标题不能为空！");
					$("#documentName").focus();
					return;
				} else if(documentName.length > 10){
					$("#span1").html("资料标题长度不能大于10");
					$("#documentName").focus();
					return;										
				}
				
				var desc = $("#desc").val();
				if(desc.trim().length == 0){
					$("#span2").html("内容不能为空！");
					$("#desc").focus();
					return;
				} else if(desc.length > 300){
					$("#span2").html("内容长度不能大于300个字！");
					$("#desc").focus();
					return;
				}
				
				
				
				$("#myform").submit();
			
			
			
				
			});
		});
	</script>
  </body>
</html>
